package com.xpmusic.dao.impl;

import com.xpmusic.dao.AdminDAO;
import com.xpmusic.model.AdminInfo;
import com.xpmusic.util.DBUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class AdminDaoImpl implements AdminDAO {

    /**
     * 验证管理员登陆信息
     * @param adminInfo
     * @return
     */
    public boolean checkAdminInfo(AdminInfo adminInfo) {
        boolean flag = false;
        SqlSession sqlSession = DBUtil.openSessionConnection();
        int i = sqlSession.selectOne("admin.checkAdminInfo",adminInfo);
        flag = i ==1;
        sqlSession.close();
        DBUtil.close();
        return flag;
    }

    /**
     * 删除歌曲
     * @param musicName
     * @return
     */
    public boolean deleteMusic(String musicName) {
        boolean flag = false;
        SqlSession sqlSession = DBUtil.openSessionConnection();
        int i = sqlSession.delete("music.deleteMusicByName",musicName);
        flag = i == 1;
        sqlSession.commit();
        return flag;
    }
}
